<template>
	<view class="flex-col homepage">

		<view class="wrapper">

			<u--form labelPosition="left" :model="form" :rules="rules" ref="form1">

		<u-form-item label="投诉类型" labelWidth="130" prop="relotion" borderBottom ref="item1">
			<view class="container">
				<uni-data-picker placeholder="请选择投诉类型" popup-title="请选择投诉类型" :localdata="dataTree"
					v-model="form.complaintsTypeId" @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
					@popupclosed="onpopupclosed" style="width: 300px;">
				</uni-data-picker>
			</view>
		
		</u-form-item>


				<u-form-item label="问题描述" labelWidth="160" prop="idCard" borderBottom ref="item1">
					<u--input v-model="form.problemDescription" border="none" placeholder="请描述您的问题"></u--input>
				</u-form-item>



				<u-form-item label="投诉人姓名" labelWidth="160" prop="phone" borderBottom ref="item1">
					<u--input v-model="form.tsname" border="none" placeholder="请输入投诉人姓名"></u--input>
				</u-form-item>

				<u-form-item label="手机号" labelWidth="120" prop="email" borderBottom ref="item1">
					<u--input v-model="form.phone" border="none" placeholder="请输入手机号码"></u--input>

				</u-form-item>

			</u--form>
		</view>

		<u-button @click="save" class="button">
			提交
		</u-button>
	</view>
</template>
<script>
	import request from '../../request.js'
	export default {
		data() {
			return {
				dataTree: [],

				form: {
					complaintsTypeId: '',
					problemDescription:'',
					tsname:'',
					phone:''
				},



			}
		},
		onLoad() {
			this.findComplaint()
		},
		methods: {
			
			findComplaint() {
				request({
					url: '/systemuser/complaints-type/appfindComplaint',
					method: 'GET',
					success: (res) => {
						console.log(res)
						if (res.data.code == 20000) {
							console.log(res.data.data.complaintsType)
							let aa = res.data.data.complaintsType
							for (var i = 0; i < aa.length; i++) {
								var param = {
									text: aa[i].type,
									value: aa[i].complaintsTypeId
								}
								this.dataTree.push(param)
							}
			
						}
					}
				})
			},
			save() {

					request({
						url: '/systemuser/complaints/appComlanints',
						data: this.form,
						method: 'POST',
						success: (res) => {
							console.log(res)
							localStorage.setItem("appComlanints",JSON.stringify(this.form))
							if (res.data.code == 20000) {
								console.log(res.data)
								uni.showToast({
									title: '提交成功',
									icon: 'success'
								})
								/* 页面跳转 */

								 setTimeout(() => {
								uni.navigateTo({
									url:'./complaintinfo'
								})
								 }, 500)
							} else {
								uni.showToast({
									title: '添加失败,信息错误失效',
									icon: 'error'
								})
							}
						}
					})

			},
			onnodeclick(e) {
				this.communityId=e.value
				console.log(this.communityId);
				console.log(e);
			},
			
			onpopupopened(e) {
				console.log('popupopened');
			},
			onpopupclosed(e) {
				console.log('popupclosed');
			},
			onchange(e) {
				console.log('onchange:', e);
			},

		},
		onShow() {

		},


	}
</script>
<style lang="scss" scoped>
	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.homepage {
		padding: 46rpx 35rpx 0rpx 35rpx;

		.text {
			width: 100%;
			height: 42rpx;
			margin-bottom: 40rpx;
			font-size: 32rpx;
			color: #bab3b5;
		}

		.wrapper {
			width: 678rpx;
			height: 4rpx;
			margin-bottom: 56rpx;
			border-top-width: 2rpx;
			border-top-style: solid;
			border-bottom-width: 2rpx;
			border-bottom-style: solid;
		}

		.upload {

			width: 100%;
			top: 50rpx;
			padding-left: 24rpx;
		}

		.upload1 {
			width: 100%;
			top: 100rpx;
			padding-left: 24rpx;
		}

		.wrapper-two {
			width: 678rpx;
			justify-content: center;
			padding: 29rpx 0rpx;
			border-radius: 20rpx;
			background: #f7f7f8;

			.text-two {
				width: 650rpx;
				height: 114rpx;
				color: #c5bbc6;
			}
		}

		.button {
			width: 694rpx;
			height: 90rpx;
			bottom: -850rpx;
			display: block;
			margin-right: auto;
			margin-left: auto;
			font-size: 36rpx;
			background: #006eff;
			color: #ffffff;
		}
	}
</style>
